import request from '@/utils/request'

export default {
  getSensorList(searchModel) {
    return request({
      url: '/sensor/list',
      method: 'get',
      params: {
        sensorName: searchModel.sensorName,
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize
      }
    })
  },
  addSensor(sensor) {
    return request({
      url: '/sensor/add',
      method: 'post',
      data: sensor
    })
  },
  saveSensor(sensor) {
    if (sensor.sensorId == null || sensor.sensorId === undefined) {
      return this.addSensor(sensor)
    }
    return this.updateSensor(sensor)
  },
  updateSensor(sensor) {
    return request({
      url: '/sensor/update',
      method: 'put',
      data: sensor
    })
  },
  getSensorById(id) {
    return request({
      // url: '/sensor/' + id,
      url: `/sensor/${id}`,
      method: 'get'
    })
  },
  deleteSensorById(id) {
    return request({
      url: `/sensor/delete/${id}`,
      method: 'delete'
    })
  },
  getAllSensorList() {
    return request({
      url: '/sensor/all',
      method: 'get'
    })
  },
}
